package com.boge.ai.rag.embedding;

import okhttp3.*;

import java.util.concurrent.TimeUnit;

public class demo1 {
    public static void main(String[] args) throws Exception{
        OkHttpClient client = new OkHttpClient().newBuilder()
                .connectTimeout(20, TimeUnit.SECONDS)
                .readTimeout(20, TimeUnit.SECONDS)
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, """
                {
                  "input": "大模型",
                  "model": "text-embedding-3-small"
                }
                """);
        Request request = new Request.Builder()
                .url("https://api.openai-hk.com/v1/embeddings")
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("Accept", "application/json")
                .addHeader("Authorization", "Bearer hk-w3q3id1000054953c829f33c861457133e3048fa220f1076")
                .build();
        Response response = client.newCall(request).execute();
        ResponseBody responseBody = response.body();
        String jsonString = responseBody.string();
        System.out.println(jsonString);
    }
}
